package com.jdk21.api.enums;

public enum ErrorCodeEnum {

    SUCCESS("000000", "SUCCESS"),
    SYSTEM_ERROR("100000", "系统错误"),
    PARAM_ERROR("100001", "参数错误"),
    USER_LOGIN_ERROR("100002", "身份认证失败，请重新登录"),
    UPLOAD_ERROR("100003", "上传失败"),
    DOWNLOAD_ERROR("100004", "下载文件失败"),
    ADMIN_LOGIN_ERROR("100005", "身份认证失败，请使用管理员账号请重新登录");

    private final String code;
    private final String desc;

    public String getCode() {
        return this.code;
    }

    public String getDesc() {
        return this.desc;
    }

    private ErrorCodeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ErrorCodeEnum getByCode(String code) {
        for(ErrorCodeEnum errorCodeEnum : values()) {
            if (errorCodeEnum.getCode().equals(code)) {
                return errorCodeEnum;
            }
        }

        return null;
    }
}
